/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const devServerPort = 8081 // TODO: get this variable from setting.ts
const name = 'VitMusic Admin' // TODO: get this variable from setting.ts

module.exports = {
  publicPath: '/',
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    port: devServerPort,
    open: true,
    overlay: {
      warnings: true,
      errors: true
    },
    progress: false
  },
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'scss',
      patterns: [
        path.resolve(__dirname, 'src/styles/_variables.scss'),
        path.resolve(__dirname, 'src/styles/_mixins.scss')
      ]
    },
    i18n: {
      locale: 'zh',
      fallbackLocale: 'en',
      localeDir: 'lang',
      enableInSFC: true
    }
  },
  chainWebpack (config) {
    // Provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    config.set('name', name)

    // https://webpack.js.org/configuration/devtool/#development
    config
      .when(process.env.NODE_ENV === 'development',
        config => config.devtool('eval-cheap-module-source-map')
      )
  }
}
